package solution._0110._0112;

import common.TreeNode;

/**
 * Created by chen_snow
 * Date: 2021/7/6 22:10
 * Description: 路径总和
 */
public class Solution {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) {
            return false;
        }

        if (root.val == targetSum && root.left == null && root.right == null) {
            return true;
        }

        return hasPathSum(root.left, targetSum - root.val) ||
                hasPathSum(root.right, targetSum - root.val);

    }
}
